package App.Service;

import App.Model.Chat.*;
import App.Model.Project.*;
import App.Repository.ChatRepository;
import App.Repository.ProjectRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.math.BigInteger;
import java.util.List;

/**
 * Created by xw on 2018/11/30.
 */
@Service
public class ChatService {

    @Autowired
    private ChatRepository _repository;

    //聊天组列表
    public ChatGroupResponse getGroupList(ChatGroupRequest request, int userid) {
        return _repository.getGroupListByPage(request, userid);
    }

    public ChatGroupResponse getGroupListV2(ChatGroupRequest request, int userid) {
        return _repository.getGroupListByPageV2(request, userid);
    }

    public ChatGroupResponse getGroupListByPageV3(ChatGroupRequest request, int userid) {
        return _repository.getGroupListByPageV3(request, userid);
    }
    public ChatGroupListResponse getStageGroup(String groupid, int userid) {
        return _repository.getStageGroup(groupid, userid);
    }

    public ChatGroupDetailResponse getGroupDetail(ChatGroupDetailRequest _request) {
        return _repository.getChatGroupDetail(_request);
    }

    public List<ChatStage> getChatStage(ChatStageGetRequest _request, int uerid) {
        return _repository.getChatStage(_request, uerid);
    }

    /*
    public List<ChatTopic> getChatTopic(ChatGetTopicRequest _request) {
        return _repository.getChatTopic(_request);
    }*/

    public int checkTopic(ChatCheckTopicRequest _request, int userid) {
        return _repository.saveGroupTopicHistory(_request, userid);
    }

    @Transactional
    public ChatGroupDetailResponse toNextStage(ChatNextStageRequest _request, int userid) {
        return _repository.toNextChatSate(_request, userid);
    }

    public int chatSend(ChatSendRequest _request, int uerid) {
        return _repository.ChatSendMessage(_request, uerid);
    }

    public List<ChatMessage> getChatMessage(ChatGetMessageRequest _request, int userid) {
        return _repository.getChatMessage(_request, userid);

    }

    //搜索
    public List<ChatGroup> searchChat(ChatSearchRequest _request, int userid) {
        return _repository.searchChat(_request, userid);
    }

    //获取阶段的详情
    public ChatGroupDetailResponse getStageDetail(ChatStageDetailRequest _request, int userid) {
        return _repository.getStageDetail(_request, userid);
    }

    //启动，结束 分支阶段
    public int operateChatBranchStage(ChatBranchStageRequest _request, int operateType, int uerid) {
        return _repository.operateChatBranchStage(_request, operateType, uerid);
    }

    public List<CrmQuestion> getQuestions() {
        return _repository.getQuestions();
    }

    public List<CrmAnswer> getAansere(int questionid) {
        return _repository.getAansere(questionid);
    }

    public int chatCallBackMessage(ChatCallBackMessage _request, int uerid) {
        return _repository.ChatCallBackMessage(_request, uerid);
    }
}
